from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

#多元素定位
driver= webdriver.Firefox()
driver.implicitly_wait(10)
driver.get("http://192.168.1.138/ranzhi/www/sys/user-login.html")
driver.maximize_window()
driver.find_element(By.XPATH,'/html/body/div/div[1]/div[1]/div/div/button').click()
driver.find_element(By.XPATH,'/html/body/div/div[1]/div[1]/div/div/ul/li[1]/a').click()
sleep(3)
driver.find_element("id","account").send_keys("admin")
driver.find_element("id","password").send_keys("123456")
driver.find_element("id","keepLoginon").click()
driver.find_element("id","submit").click()
driver.find_element(By.XPATH,'/html/body/div[1]/div[1]/div/ul[1]/li[2]/button/img').click()
#框架的切入 : driver.switch_to.frame("iframe_superadmin")
driver.switch_to.frame("iframe-1")
driver.find_element(By.XPATH,'/html/body/nav/ul/li[4]/a').click()
driver.find_element(By.XPATH,'/html/body/div[2]/div[1]/a').click()
driver.find_element(By.XPATH,'//*[@id="name"]').send_keys("大主播")
driver.find_element("id","contact").send_keys("卢本伟")
driver.find_element("id","phone").send_keys("12128123")
driver.find_element("id","email").send_keys("lubenweinb@163.com")
driver.find_element("id","qq").send_keys("112233445")
driver.find_element("id","depositor").send_keys("平安银行12138")
from selenium.webdriver.support.select import Select
ele1=driver.find_element("id","type")
sle_obj1=Select(ele1)
sle_obj1.select_by_value("personal")
ele=driver.find_element("id","size")
sle_obj=Select(ele)
sle_obj.select_by_value("4")
ele=driver.find_element("id","status")
sle_obj=Select(ele)
sle_obj.select_by_value("intension")
ele=driver.find_element("id","level")
sle_obj=Select(ele)
sle_obj.select_by_value("A")
driver.find_element("id","addresstitle").send_keys("斗鱼直播")
driver.find_element("id","addresslocation").send_keys("上海市")
driver.find_element("id","intension").send_keys("强")
driver.find_element("id","submit").click()
sleep(2)
driver.switch_to.parent_frame() #返回上一级框架
driver.find_element(By.XPATH,'/html/body/div[1]/div[1]/div/ul[1]/li[8]/button/i').click()
driver.switch_to.frame("iframe-superadmin")
driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div[1]/div/a/h3').click()
driver.find_element("id","account").send_keys("Royalwhite3zz")
driver.find_element("id","realname").send_keys("卢本伟")
driver.find_element("id","genderm").click()
ele=driver.find_element("id","role")
sle_obj=Select(ele)
sle_obj.select_by_value("supportmgr")
driver.find_element("id","password1").send_keys("123456")
driver.find_element("id","password2").send_keys("123456")
driver.find_element("id","email").send_keys("lubenweinb@163.com")
driver.find_element("id","submit").click()
# #下拉框操作
# from selenium.webdriver.support.select import Select
# #定位到下拉框
# ele=driver.find_element(By.ID,"role")
# #创建下拉框对象
# sle_obj=Select(ele)
# #调用方法
# # sle_obj.select_by_index(3)
# # sle_obj.select_by_visible_text("市场主管")
# sle_obj.select_by_value("top")
# sleep(2)
# #返回根框架
driver.switch_to.parent_frame() #返回上一级框架
# driver.find_element(By.LINK_TEXT,"签退").click()
sleep(2)
driver.quit()


